package net.kts.placebook.tips;

import java.util.ArrayList;

import net.kts.main.R;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


public class TipsAdapter extends BaseAdapter {
	
	private ArrayList<Tips> tipList;
	private LayoutInflater mInflater;
	
	public TipsAdapter(Context c) {
		mInflater = LayoutInflater.from(c);
	}
	
	public void setData(ArrayList<Tips> poolList){
		tipList = poolList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return tipList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return tipList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		ViewHolder holder;

		if (convertView == null) {
			convertView	=  mInflater.inflate(R.layout.pb_venue_info_row, null);

			holder = new ViewHolder();

			holder.writerNameTxt 	= (TextView) convertView.findViewById(R.id.writer_name);
			holder.textTxt	 		= (TextView) convertView.findViewById(R.id.text);


			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		Tips tips = tipList.get(position);
		
		Log.i("fs333", "유저 네임 : " + tips.getUserName());
		Log.i("fs333", "팁 내용 : " + tips.getText());
		
		holder.writerNameTxt.setText(tips.getUserName());
		holder.textTxt.setText(tips.getText());
		
        return convertView;
	}
	
	static class ViewHolder {
		TextView writerNameTxt;
		TextView textTxt;
	}

}
